<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<!--    <form action="postParameter" method="post">-->
<!--        <input type="text" name="aa">-->
<!--        <input type="text" name="bb">-->
<!--        <input type="submit" value="提交">-->
<!--    </form>-->


<!--    <script src="./jquery.js"></script>-->
<!--    <script>-->
<!--        $.ajax({-->
<!--            type: 'post',-->
<!--            url: 'method',-->
<!--            success: function (body) {-->
<!--                console.log(body);-->
<!--            }-->
<!--        });-->
<!--    </script>-->


<!--要想构造一个json格式的对象，就使用Ajax-->
    <input type="text" id="aa">
    <input type="text" id="bb">
    <input type="submit" value="提交" id="submit">

    <script src="./jquery.js"></script>
    <script>
        let button = document.querySelector("#submit");
        let aa = document.querySelector("#aa");
        let bb = document.querySelector("#bb");
        button.onclick = function(){
            $.ajax({
                type: 'post',
                url: 'postJson',
                // 将 js对象转为JSON字符串发送给服务器
                data: JSON.stringify({
                    aa: aa.value,
                    bb: bb.value,
                }),
                success: function (body) {
                    document.write(body)
                }
            });
        }
    </script>

<!--    <script src="./jquery.js"></script>-->
<!--    <script>-->
<!--        $.ajax({-->
<!--            type: 'delete',-->
<!--            url: 'hello',-->
<!--            success:function (body) {-->
<!--                console.log(body)-->
<!--            }-->
<!--        })-->
<!--    </script>-->

</body>
</html>